package com.lab.mapper;

import com.github.pagehelper.Page;
import com.lab.dto.MemberPageQueryDTO;
import com.lab.entity.Member;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MemberMapper {


    /**
     * 新增用户
     * @param member
     */
    @Insert("insert into member (id,name,grade,major,student_id,role_type,is_on_leave,create_time,update_time,password,role)" +
            " values " +
            "(#{id},#{name},#{grade},#{major},#{studentId},#{roleType},#{isOnLeave},#{createTime},#{updateTime},#{password},#{role})")
    // 如果需要返回自增ID
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Member member);


    /**
     * 分页查询
     * @param memberPageQueryDTO
     * @return
     */
    Page<Member> pageQuery(MemberPageQueryDTO memberPageQueryDTO);


    /**
     * 根据name查询
     * @param name
     * @return
     */
    @Select("select * from member where name=#{name}")
    Member getByNamez(String name);


    /**
     * 修改成员信息
     * @param member
     */
    void update(Member member);


    /**
     * 删除成员信息
     * @param id
     * @return
     */
    @Delete("delete from member where id=#{id}")
    int deleteById(Long id);


    //魏子洋
    Member selectById(Integer memberId);

    List<Member> getByName(@Param("name") String name);

    /**
     * 根据学号查询成员信息
     * @param studentId 学号
     * @return 成员信息
     */
    Member getByStudentId(@Param("studentId") String studentId);

    /**
     * 根据姓名查询成员信息
     * @param name 姓名
     * @return 成员信息
     */
    Member getByNameSingle(@Param("name") String name);

}
